//
//  MBProgressHUD+XDPrompt.m
//  tangchengyipin
//
//  Created by XiangDongMBP on 16/3/15.
//  Copyright © 2016年 XiangDong. All rights reserved.
//

#import "MBProgressHUD+XDPrompt.h"

NSTimeInterval const kXDAutoHideTimeLength = 1.5;

@implementation MBProgressHUD (XDPrompt)

+ (instancetype)showPromptWithAutoHideInView:(UIView *)view message:(NSString *)msg {
    MBProgressHUD * hud = [[self class] showHUDAddedTo:view animated:YES];
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.backgroundColor = [UIColor blackColor];
    hud.contentColor = [UIColor whiteColor];
    
//    hud.label.font = [UIFont systemFontOfSize:14];
    
    hud.mode = MBProgressHUDModeText;
    if ([msg isKindOfClass:[NSString class]]) {
        hud.label.text = msg;
        hud.label.numberOfLines = 2;
//        hud.detailsLabel.text = msg;
    }
    hud.removeFromSuperViewOnHide = YES;
//    [hud hide:YES afterDelay:kXDAutoHideTimeLength];
    [hud hideAnimated:YES afterDelay:kXDAutoHideTimeLength];
    return hud;
}

+ (instancetype)xd_showHUDAddedTo:(UIView *)view animated:(BOOL)animated {
    MBProgressHUD *hud = [self showHUDAddedTo:view animated:YES];
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.backgroundColor = [UIColor blackColor];
    hud.contentColor = [UIColor whiteColor];
    
    return hud;
}

@end
